<template>
  <elm-page-tb>
    <template #top>
      <el-input placeholder="请查询输入内容" prefix-icon='el-icon-search' size="mini" style="width: 250px;" v-model="postData.col_1" clearable></el-input>
      <right>
        <el-button-group>
          <el-button icon="el-icon-search" size="mini" @click="v_getData()">查询</el-button>
          <elm-open-button url="/system/flow/one_road_flowsec_form_s" width="700" height="450" title="新增"
                           :data="{'page_type':'create','flow_code':flow_code,'model':null,'node_submit':node_submit}"
                           icon="el-icon-edit">新增</elm-open-button>
        </el-button-group>
      </right>
    </template>
    <elm-table url="/system/login/flow/FlowsecFormItem_GetData" :post-data="postData" :default-expand-all="true" height="100%">
      <el-table-column prop="sys_code_key" label="流程号" width="200px"  align="center"></el-table-column>
      <el-table-column prop="sys_createtime" label="申请时间" align="center" width="100">
        <template v-slot="scope">
          {{ elm.parseTime(scope.row.sys_createtime) }}
        </template>
      </el-table-column>
      <el-table-column prop="col_1" label="出差目的" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_2" label="出发地点" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_3" label="出差地点" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_4" label="开始日期" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_5" label="结束日期" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_6" label="出差天数" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_7" label="交通工具" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_8_str" label="关联项目" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_9_str" label="关联商机" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_10_str" label="关联线索" width="120px" align="center"></el-table-column>
      <el-table-column prop="col_11" label="备注" width="120px" align="center"></el-table-column>
      <el-table-column fixed="right" label="当前节点" width="160px" align="center">
        <template v-slot="scope">
          <elm-open-button url="/system/flow/flow_canvas" theme="white" :full="false" width="90%" height="90%" title="节点信息"
                           :data="{'show_flowins':'yes','flow_code':flow_code,'data_id':scope.row.id}"
                           v-if="!em(scope.row.nodeins_id)" type="text">
            {{scope.row.nodeins_status=='completed'?'流程已完成':scope.row.last_nodeins_title}}</elm-open-button>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="160px" align="center">
        <template v-slot="scope">
          <elm-open-button url="/system/flow/one_road_flowsec_form_s" width="700" height="450" title="编辑"
                           :data="{'page_type':'edit','flow_code':flow_code,'model':scope.row,'node_submit':node_submit}"
                           v-if="v_showSubmit(scope.row)" type="text">编辑</elm-open-button>
          <elm-open-button url="/system/flow/one_road_flowsec_form_s" width="700" height="450" title="信息"
                           :data="{'page_type':'show','flow_code':flow_code,'model':scope.row}"
                           type="text">查看</elm-open-button>
        </template>
      </el-table-column>
    </elm-table>
  </elm-page-tb>
</template>

<script>
export default {
  extends: elmVueBase,
  data() {
    return {
      loading:true,
      dataList:[],

      postData: {
        pageNum: 1, pageSize: 20, count: 0,
        flow_code:'business_trip',
      },
      flow_code:'business_trip',
      allowInitFlow:false,
      node_submit:',出差申请,结束出差,',

      needConsole:true,
    }
  },
  mounted() {
    this.v_getData();
  },
  methods: {
    async v_getData(){
      this.tablebinding();
    },
    v_showSubmit:function(data){
      this.v_consoleData(data);

      if(this.em(data.nodeins_id)){return this.allowInitFlow;}
      else if(data.nodeins_status!='running' || data.preson_status!='running'){return false;}

      let check = !this.em(data.nodeins_title) && this.node_submit.indexOf(','+data.nodeins_title+',')>=0;
      return check;
    },
    v_consoleData:function(data){
      if(this.needConsole){ console.log(JSON.stringify(data)); }
    },

    em: function (s) {
      if (s == null || s == '') { return true; }
      else { return false; }
    },

  }
}
</script>
<style>
.one_road .elm-body{padding: 5px;}
</style>